#pragma once
#include "DVertexBuffer.h"
#include "../DVector3.h"

namespace Skill
{
	namespace Ode
	{
		namespace Geometries
		{
			void DVertexBuffer::CollectManagedMemory()
			{			
			}

			void DVertexBuffer::SetData(array<float>^ data,int startIndex,int lenght)
			{
				Marshal::Copy(data,startIndex,UnmanagedPointer,lenght);
			}		
			void DVertexBuffer::SetData(array<float>^ data)
			{
				SetData(data,0,data->Length);
			}

			void DVertexBuffer::SetVertex(int vertexIndex,dReal x,dReal y,dReal z)
			{			
				dReal* p = _This + 3 * vertexIndex;
				p[0] = x;
				p[1] = y;
				p[2] = z;
			}
			void DVertexBuffer::SetVertex(int vertexIndex,DVector3^ vertex)
			{
				SetVertex(vertexIndex,vertex->_This[0],vertex->_This[1],vertex->_This[2]);
			}

			void DVertexBuffer::SetHeightAt(int vertexIndex , dReal height)
			{
				dReal* p = _This + 3 * vertexIndex + 1;
				p[0] = height;
			}
			dReal DVertexBuffer::GetHeightAt(int vertexIndex)
			{
				dReal* p = _This + 3 * vertexIndex + 1;			
				return p[0];
			}

			DVector3^ DVertexBuffer::GetReferenceVertex(int vertexIndex)
			{
				dReal* p = _This + 3 * vertexIndex;
				return gcnew DVector3(p);
			}

			int DVertexBuffer::SizeInByte::get()
			{
				return sizeInByte;
			}
			int DVertexBuffer::VertexCount::get()
			{
				return vertexCount;
			}
			int DVertexBuffer::VertexStride::get()
			{
				return 12;
			}
		}
	}
}